package demo2;

import demo1.ReflectClassDemo;
import jdk.internal.org.objectweb.asm.tree.MultiANewArrayInsnNode;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: wx
 * Date: 2024-05-04
 * Time: 17:38
 */
public enum TestEnum {
    RED(1,"红色"),
    GREEN(2,"绿色"),
    BLACK(3,"黑色");

    private int ordinal;
    private String color;
    TestEnum(int ordinal, String color) { //枚举的构造方法,默认是私有的
        this.ordinal = ordinal;
        this.color = color;
    }

    public static void main2(String[] args) {
        TestEnum[] values = TestEnum.values();
        for (int i = 0; i < values.length; i++) {
            System.out.println(values[i].ordinal());
        }
        System.out.println("======================");
        TestEnum v = TestEnum.valueOf("BLACK");
        System.out.println(v);
        System.out.println("======================");
        System.out.println(RED.compareTo(BLACK));
    }
    public static void main1(String[] args) {
        TestEnum color = RED;
        switch (color) {
            case GREEN:
                System.out.println("GREEN");
                break;
            case RED:
                System.out.println("RED");
                break;
            case BLACK:
                System.out.println("BLACK");
                break;
            default:
                System.out.println("error");
                break;
        }
    }
}
